package com.x.service.entity.map;

import com.x.service.entity.ChapterList;
import com.x.service.entity.ChaptersInfo;
import com.x.zssqservice.bean.BookMixAToc;

import java.util.ArrayList;

/**
 * Created by H on 18/5/9.
 */

public class BookMixATocToChapterList implements IMap<BookMixAToc, ChaptersInfo> {
    @Override
    public ChaptersInfo map(BookMixAToc bookMixAToc) {
        ChaptersInfo chaptersInfo = new ChaptersInfo();
        chaptersInfo.ok = bookMixAToc.ok;
        ChapterList chapterList = new ChapterList();
        chapterList._id = bookMixAToc.mixToc._id;
        chapterList.book = bookMixAToc.mixToc.book;
        chapterList.updated = bookMixAToc.mixToc.chaptersUpdated;
        chapterList.chapters = new ArrayList<>();
        for (BookMixAToc.mixToc.Chapters chapter : bookMixAToc.mixToc.chapters) {
            ChapterList.BookChapter bookChapter = new ChapterList.BookChapter();
            bookChapter.id = chapter.id;
            bookChapter.link = chapter.link;
            bookChapter.title = chapter.title;
            bookChapter.unreadble = chapter.unreadble;
            chapterList.chapters.add(bookChapter);
        }
        chaptersInfo.chapterInfo = chapterList;
        return chaptersInfo;
    }
}
